#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void game()
{
    int in;
    int over = rand() % 100 + 1;

    while (1)
    {
        printf("\n");
        printf("请输入你猜测的数字：");
        scanf("%d", &in);
        if (in > over)
        {
            printf("猜大了\n");
            continue;
        }
        else if (in < over)
        {
            printf("猜小了\n");
            continue;
        }
        else
        {
            printf("猜对了\n");
            break;
        }
    }
}

int main()
{
    srand((unsigned int)time(NULL));
    int c;
    char con;
    printf("1.进入游戏 0.退出游戏\n");
    printf("请选择你的操作\n");

    do
    {
        scanf("%d", &c);
        switch (c)
        {
        case 1:
            do
            {
                game();
                printf("是否继续游戏\n 'Y':继续游戏  'N':退出游戏\n");
                scanf("%s", &con);
                if (con == 'N')
                {
                    printf("退出游戏\n");
                    break;
                }
            } while (con == 'Y');
            break;
        case 0:
            printf("退出游戏\n");
            break;
        default:
            printf("输入错误,请重新输入!");
            break;
        }
    } while (c != 1 && c != 0);
    return 0;
}